/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class SellerListingSearchRequest
    {
    
        private String keywordsField;

        private Decimal? listingPageField;

        private String offerStatusField;

        private List<String> responseGroupField;

        private String sellerIdField;

        private String sortField;

        private String titleField;


        /// <summary>
        /// Gets and sets the Keywords property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Keywords")]
        public String Keywords
        {
            get { return this.keywordsField ; }
            set { this.keywordsField= value; }
        }



        /// <summary>
        /// Sets the Keywords property
        /// </summary>
        /// <param name="keywords">Keywords property</param>
        /// <returns>this instance</returns>
        public SellerListingSearchRequest WithKeywords(String keywords)
        {
            this.keywordsField = keywords;
            return this;
        }



        /// <summary>
        /// Checks if Keywords property is set
        /// </summary>
        /// <returns>true if Keywords property is set</returns>
        public Boolean IsSetKeywords()
        {
            return  this.keywordsField != null;

        }


        /// <summary>
        /// Gets and sets the ListingPage property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ListingPage")]
        public Decimal ListingPage
        {
            get { return this.listingPageField.GetValueOrDefault() ; }
            set { this.listingPageField= value; }
        }



        /// <summary>
        /// Sets the ListingPage property
        /// </summary>
        /// <param name="listingPage">ListingPage property</param>
        /// <returns>this instance</returns>
        public SellerListingSearchRequest WithListingPage(Decimal listingPage)
        {
            this.listingPageField = listingPage;
            return this;
        }



        /// <summary>
        /// Checks if ListingPage property is set
        /// </summary>
        /// <returns>true if ListingPage property is set</returns>
        public Boolean IsSetListingPage()
        {
            return  this.listingPageField != null;

        }


        /// <summary>
        /// Gets and sets the OfferStatus property.
        /// </summary>
        [XmlElementAttribute(ElementName = "OfferStatus")]
        public String OfferStatus
        {
            get { return this.offerStatusField ; }
            set { this.offerStatusField= value; }
        }



        /// <summary>
        /// Sets the OfferStatus property
        /// </summary>
        /// <param name="offerStatus">OfferStatus property</param>
        /// <returns>this instance</returns>
        public SellerListingSearchRequest WithOfferStatus(String offerStatus)
        {
            this.offerStatusField = offerStatus;
            return this;
        }



        /// <summary>
        /// Checks if OfferStatus property is set
        /// </summary>
        /// <returns>true if OfferStatus property is set</returns>
        public Boolean IsSetOfferStatus()
        {
            return this.offerStatusField != null;

        }


        /// <summary>
        /// Gets and sets the ResponseGroup property.
        /// </summary>
        [XmlElementAttribute(ElementName = "ResponseGroup")]
        public List<String> ResponseGroup
        {
            get
            {
                if (this.responseGroupField == null)
                {
                    this.responseGroupField = new List<String>();
                }
                return this.responseGroupField;
            }
            set { this.responseGroupField =  value; }
        }



        /// <summary>
        /// Sets the ResponseGroup property
        /// </summary>
        /// <param name="list">ResponseGroup property</param>
        /// <returns>this instance</returns>
        public SellerListingSearchRequest WithResponseGroup(params String[] list)
        {
            foreach (String item in list)
            {
                ResponseGroup.Add(item);
            }
            return this;
        }          
 


        /// <summary>
        /// Checks of ResponseGroup property is set
        /// </summary>
        /// <returns>true if ResponseGroup property is set</returns>
        public Boolean IsSetResponseGroup()
        {
            return (ResponseGroup.Count > 0);
        }




        /// <summary>
        /// Gets and sets the SellerId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "SellerId")]
        public String SellerId
        {
            get { return this.sellerIdField ; }
            set { this.sellerIdField= value; }
        }



        /// <summary>
        /// Sets the SellerId property
        /// </summary>
        /// <param name="sellerId">SellerId property</param>
        /// <returns>this instance</returns>
        public SellerListingSearchRequest WithSellerId(String sellerId)
        {
            this.sellerIdField = sellerId;
            return this;
        }



        /// <summary>
        /// Checks if SellerId property is set
        /// </summary>
        /// <returns>true if SellerId property is set</returns>
        public Boolean IsSetSellerId()
        {
            return  this.sellerIdField != null;

        }


        /// <summary>
        /// Gets and sets the Sort property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Sort")]
        public String Sort
        {
            get { return this.sortField ; }
            set { this.sortField= value; }
        }



        /// <summary>
        /// Sets the Sort property
        /// </summary>
        /// <param name="sort">Sort property</param>
        /// <returns>this instance</returns>
        public SellerListingSearchRequest WithSort(String sort)
        {
            this.sortField = sort;
            return this;
        }



        /// <summary>
        /// Checks if Sort property is set
        /// </summary>
        /// <returns>true if Sort property is set</returns>
        public Boolean IsSetSort()
        {
            return  this.sortField != null;

        }


        /// <summary>
        /// Gets and sets the Title property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Title")]
        public String Title
        {
            get { return this.titleField ; }
            set { this.titleField= value; }
        }



        /// <summary>
        /// Sets the Title property
        /// </summary>
        /// <param name="title">Title property</param>
        /// <returns>this instance</returns>
        public SellerListingSearchRequest WithTitle(String title)
        {
            this.titleField = title;
            return this;
        }



        /// <summary>
        /// Checks if Title property is set
        /// </summary>
        /// <returns>true if Title property is set</returns>
        public Boolean IsSetTitle()
        {
            return  this.titleField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetKeywords()) {
                xml.Append("<Keywords>");
                xml.Append(EscapeXML(this.Keywords));
                xml.Append("</Keywords>");
            }
            if (IsSetListingPage()) {
                xml.Append("<ListingPage>");
                xml.Append(this.ListingPage);
                xml.Append("</ListingPage>");
            }
            if (IsSetOfferStatus()) {
                xml.Append("<OfferStatus>");
                xml.Append(this.OfferStatus);
                xml.Append("</OfferStatus>");
            }
            List<String> responseGroupList  =  this.ResponseGroup;
            foreach (String responseGroup in responseGroupList) { 
                xml.Append("<ResponseGroup>");
                xml.Append(responseGroup);
                xml.Append("</ResponseGroup>");
            }	
            if (IsSetSellerId()) {
                xml.Append("<SellerId>");
                xml.Append(EscapeXML(this.SellerId));
                xml.Append("</SellerId>");
            }
            if (IsSetSort()) {
                xml.Append("<Sort>");
                xml.Append(EscapeXML(this.Sort));
                xml.Append("</Sort>");
            }
            if (IsSetTitle()) {
                xml.Append("<Title>");
                xml.Append(EscapeXML(this.Title));
                xml.Append("</Title>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}